const 距您 = 5;
const 全程 = 10;

//距离限制
(() => {
    log('开始执行')
    while (1) {
        
        let pLayout = id("content").findOne()


        let qd_button = pLayout.findOne(textContains('立即抢单'))
        if (qd_button) {
            log('抢单')
            //开始判断距离
            let jl_text = qd_button.parent().find(textMatches(/\d{1,2}\.\d{1,2}/))
            // log("x:%d, y:%d", qd_button.bounds().centerX(), qd_button.bounds().centerY())
            // log(qd_button.text())
            if (jl_text.length > 1) {
                log(Number(jl_text[0].text()))
                if (Number(jl_text[0].text()) <= 距您 && Number(jl_text[1].text()) <= 全程) {
                    log('距离合适')
                    //开始判断预约单
                    if (pLayout.findOne(textContains('预约'))) {
                        log('预约单')
                    } else {
                        log('非预约单')
                    }
                } else {
                    log('距离不合适')
                }
            }
            // while(!qd_button.click());

        } else {
            log('---')
        }
    }
})()
